//index.js
//获取应用实例
const app = getApp()

Page({
  data: {
     line:'eee',
     imgstate:'inline-block',
     inputValue:'15238207952',
     inputNext:'bgline',
     loginGif:'none'
  },
 
  onLoad(val) {
        this.setData({
            inputValue:wx.getStorageSync('myPhone')
        })
        console.log(val)
  },
  clickfocus(){
      this.setData({
          line:'2b93f6',
          imgstate:'inline-block' 
        })
  },
  clickblur(e){
      console.log(e);
      let mobile = e.detail.value;
      this.setData({
          line: 'eee',
          imgstate: 'none' 
      })
      if (mobile.length == 0) {
          wx.showToast({
              title: '请输入手机号！',
              
              duration: 1500
          })
          this.setData({
              inputNext: ''
          })
          return false;
      }
      if (mobile.length != 11) {
          wx.showToast({
              title: '手机号长度有误！',
              duration: 1500
          })
          this.setData({
              inputNext: ''
          })
          return false;
      }
      var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1})|(17[0-9]{1}))+\d{8})$/;
      if (!myreg.test(mobile)) {
          wx.showToast({
              title: '手机号有误！',
              icon: 'success',
              duration: 1500
          })
          this.setData({
              inputValue: '',
          })
          return false;
      }
      this.setData({
          inputNext:'bgline'
      })
      return true;
  },
  clickClear(e){
      this.setData({
          inputValue: '',
      })
  },
  clickInput(e){
      let phoneMsg = e.detail.value;     
      var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1})|(17[0-9]{1}))+\d{8})$/;
      if (myreg.test(phoneMsg)) {
          this.setData({
              inputNext: 'bgline'
             
          })
          
      }
  }, 
    code(){
        let _this=this;
        this.setData({
            loginGif:'block'
        })
        wx.reLaunch({
            url: '/pages/index/lymap/lymap',
            success:()=>{
                _this.setData({
                    loginGif: 'none'
                })
            },
            fali:()=>{
                _this.setData({
                    loginGif: 'none'
                })
            },
            complete:()=>{
               
            }
        })     
    }
})
